import request from "@/utils/request";

//商品相关api
const producApi = {
	//获取所有分类
	getCategoryList() {
		return request.get<dataResult>({ url: "/api/customer/product/getcategorylist" });
	},
	//获取推荐商品
	getRecommenDproduct() {
		return request.get<dataResult>({ url: "/api/customer/product/getrecommendlist" });
	},
	//获取商品列表
	getProductList(data : ProductlistParams) {
		return request.post<dataResult>({ url: "/api/customer/product/getlist", data });
	},
	//获取商品详情
	getProduct(data : ProductParams) {
		return request.post<dataResult>({ url: "/api/customer/product/getdetail", data });
	},
	//获取调价记录
	getPriceList(data : PriceParams) {
		return request.post<dataResult>({ url: "/api/customer/product/getpriceadjustmentlist", data });
	},
	//订阅列表
	getsubscribelist(data : GetsubscribelistParams) {
		return request.post<dataResult>({ url: "/api/customer/product/getsubscribelist", data });
	},
	//商品订阅
	subscribe(data : SubscribeParams) {
		return request.post<dataResult>({ url: "/api/customer/product/subscribe", data });
	},
	//取消订阅
	subscribedel(data : SubscribedelParams) {
		return request.post<dataResult>({ url: "/api/customer/product/subscribedel", data });
	},
	//收藏列表
	getfavoritelist(data : GetfavoritelistParams) {
		return request.post<dataResult>({ url: "/api/customer/product/getfavoritelist", data });
	},
	//商品收藏
	favorite(data : FavoriteParams) {
		return request.post<dataResult>({ url: "/api/customer/product/favorite", data });
	},
	//取消收藏
	favoritedel(data : FavoritedelParams) {
		return request.post<dataResult>({ url: "/api/customer/product/favoritedel", data });
	},
	//浏览记录
	getbrowselist() {
		return request.get<dataResult>({ url: "/api/customer/product/getbrowselist" });
	}
};

export default producApi;

interface dataResult {
	data ?: any;
	message : string;
	status : number;
}

//获取商品列表请求参数
interface ProductlistParams {
	category_id : number | null;
}

//获取商品详情请求参数
interface ProductParams {
	id : number;
}

//调价记录请求参数
interface PriceParams {
	page : number;
	limit : number;
	keyword : string;
	keyword_type : string;
}

//订阅列表请求参数
interface GetsubscribelistParams {
	page : number;
	limit : number;
	keyword : string;
	keyword_type : string;
}

//商品订阅请求参数
interface SubscribeParams {
	ids : number[];
}

//取消订阅请求参数
interface SubscribedelParams {
	ids : number[];
}

//收藏列表请求参数
interface GetfavoritelistParams {
	page : number;
	limit : number;
}

//商品收藏请求参数
interface FavoriteParams {
	id : number;
}

//取消订阅请求参数
interface FavoritedelParams {
	id : number;
}